function brandJs() {
    let text = document.getElementById("text")
    let main = document.getElementById("main")
    window.onload = function() {
        //获取浏览器的query参数
        function getUrlParams() {
            let href = location.href;
            let regExp = /.+\?(.+)/
            let param = regExp.exec(href)[1]
                // console.log(param);
                // console.log(decodeURI(param));解码URI的参数编码

            let paramArr = param.split("&");
            // console.log(paramArr);
            let query = {}
            paramArr.forEach(item => {
                itemArr = item.split("=");
                // console.log(itemArr);
                query[itemArr[0]] = decodeURI(itemArr[1])
            })

            return query
        }
        let query = getUrlParams() //获取浏览器query参数
        console.log(query);
        text.innerText = query.brandName;
        renderAjax(query.brandtitleid, 20)

        function renderAjax(brandId, pagesize) {
            ajax({
                url: "http://chst.vip:1234/api/getbrandproductlist?brandtitleid=" + brandId + "&pagesize=" + pagesize + "",
                success(res) {
                    let data = res.result
                    console.log(data);
                    let html = ""
                    data.forEach(item => {
                        html += `
                    <a href="productlist.html?title=${item.brandName}&productId=${item.productId}">
                  ${item.productImg}
                    <div>
                        <p>${item.productName}</p>
                        <p>${item.productPrice}</p>
                        <div>
                            <span>${item.productQuote}</span>
                            <span><em><img src="../images/icon_bar.png" alt=""></em>${item.productCom}</span>
                        </div>
                    </div>
                </a>`
                    })
                    main.innerHTML = html
                }
            })
        }

    }
}
brandJs()